﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for KeyFigures
/// </summary>
public static class CalKeyFigures
{
      public static int grossMargin(int revenue, int directCost)
    {
			int grossMargin = revenue - directCost;
			return grossMargin;
		}

    public static double grossMarginRatio(int revenue, int directCost)
    {
			double grossMarginRatio = (double) (revenue-directCost) / revenue;
			return grossMarginRatio;
		}

    public static double operatingMargin(int revenue, int result)
    {
			double operatingMargin = (double) result/revenue;
			return operatingMargin;
		}

    public static double ROI(int result, int longTermAssets, int shortTermAssets)
    {
			double ROI = (double) result / (longTermAssets + shortTermAssets);
			return ROI;
		}

    public static double returnOnEquity(int result, int equityPrimo, int equityUltimo)
    {
			double returnOnEquity = (double) result / (equityPrimo*0.5 + equityUltimo*0.5);
			return returnOnEquity;
		}

    public static double solvencyRatio(int equity, int longTermAssets, int shortTermAssets)
    {
			double solvencyRatio = (double) equity / (longTermAssets + shortTermAssets);
			return solvencyRatio;
		}

    public static double liquidityRatio(int shortTermAssets, int shortTermLiabilities)
    {
			double liquidityRatio = (double) shortTermAssets / shortTermLiabilities;
			return liquidityRatio;
		}

    public static double KI(double sharePrice, int equity, double numberOfShares)
    {
			double KI = (double) sharePrice * numberOfShares/equity;
			return KI;
		}

    public static double PE(double sharePrice, double numberOfShares, int result)
    {
			double PE = (double) sharePrice * numberOfShares / result;
			return PE;
		}

    public static double EPS(int result, double numberOfShares)
    {
			double EPS = (double) result / numberOfShares;
			return EPS;
		}

    public static double PEGRatio(double EPSyearOne, double EPSyearTwo, double PE, double growthEPS)
    {
      if (growthEPS == 0)
      {
        return 0;
      }
      else
      {
        double PEGRatio = PE / growthEPS * 100;
        return PEGRatio; 
      }
		}

    private static double growthEPS(double yearOne, double yearTwo)
    {
			double growth = 0;
			if(yearOne == 0){
				return growth;
			}else{
				growth = (yearTwo - yearOne) / yearOne;
				return growth;
			}
		}

    private static double dividendPrShare(int dividend, double numberOfShares)
    {
			double dividendPrShare = 0;
			if(dividend == 0){
				return dividendPrShare;
			}else{
				return dividendPrShare = (double) dividend / numberOfShares;
			}
		}

    private static double dividendPrStockPrice(double dividendPrShare, double sharePrice, int dividend)
    {
			double dividendPrStockPrice = 0;
			if(dividend == 0){
				return dividendPrStockPrice;
			}else{
				return dividendPrStockPrice = dividendPrShare / sharePrice;
			}
			
		}
} 